import shapefile

r = shapefile.Reader("shapefiles/MS_UrbanAnC10/MS_UrbanAnC10")
w = shapefile.Writer("shapefiles/MS_UrbanAnC10/MS_Urban_Subset")
w.fields = list(r.fields)
for item in r.shapeRecords():
    # 筛选人口小于5000,
    if item.record[14] < 5000:
        w.record(*item.record)
        w.shape(item.shape)
r.close()
w.close()

# 验证结果
r = shapefile.Reader("shapefiles/MS_UrbanAnC10/MS_Urban_Subset")
for rec in r.shapeRecords():
    print(rec.record[3], rec.record[14])
r.close()